package com.xyzwps.paimon.furina.modules.tag

import com.xyzwps.paimon.furina.common.value.PageSize
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.transactions.transaction
import org.springframework.stereotype.Service

@Service
class TagApp(private val tagService: TagService, private val db: Database) {

    fun create(domain: Int, name: String): Tag = transaction(db) {
        tagService.create(TagDomain.validDomain(domain), name)
    }

    fun searchTags(domain: Int, prefix: String, size: PageSize): List<Tag> = transaction(db) {
        tagService.findByPrefix(domain, prefix, size)
    }

}